<script>
    // 转大写
    let str1 = "abc";
    console.log(str1.toUpperCase());

    // 转小写
    let str2 = "aBc";
    console.log(str2.toLowerCase());

    // 获取指定下标的字符
    let str3 = "hello";
    console.log(str3.charAt(2));
    console.log(str3.charAt(20));

    // 截取字符串
    let str4 = "helloworld";
    console.log(str4.substring(1, 5)); // ello  1-4
    console.log(str4.substring(5)); // world 5之后

    // 思考题：将字符串首字母大写吗，其他字母小写
    let title = "aBCdEf";
    let result = title.charAt(0).toUpperCase() + title.substring(1).toLowerCase();
    console.log(result);

    // 去除空格
    let str5 = "   hello   ";
    console.log(str5.trim());
    console.log(str5.trimEnd());
    console.log(str5.trimStart());

    // 判断是否存在子串
    let str6 = "hello";
    console.log(str6.includes("el"));
    console.log(str6.includes("efsdfgsgl"));

    // 检测子串存在目标字符串中的首次下标，没找到返回 -1
    let str7 = "helloel";
    console.log(str6.indexOf("el")); // 1
    console.log(str6.indexOf("efsdfgsgl")); // -1

    // 重复一个字符串多少次
    let str8 = "abc";
    console.log(str8.repeat(3));

    // 替换字符串
    let str9 = "i like eat apple";
    console.log(str9.replace("apple", "orange"));

    // 用特定字符炸开字符串
    let str10 = "A|B|C";
    console.log(str10.split("|"));
</script>